package com.corn.controller;

import com.corn.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/hello")
public class HelloHandler {
    @RequestMapping(value = "/index",method = RequestMethod.POST,params = {"id=1","name=tom"})
    public String index(Integer id,String name){
        System.out.println("接收到了请求,参数是：id="+id+",name="+name);
        return "index";
    }

    @RequestMapping("/restful/{id}/{name}")
    public String restful(@PathVariable("id") Integer id,@PathVariable("name") String name){
        System.out.println(id+"-"+name);
        return "index";
    }

    @RequestMapping("/cookie")
    public String getCookie(@CookieValue("JSESSIONID") String sessionId){
        System.out.println(sessionId);
        return "index";
    }

   @RequestMapping(value = "/add")
   public String add(User user){
       System.out.println(user);
       return "index";
   }
}

